﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Judgment
    {
        public static void Test()
        {
            //接对方角色名
            string ing = "未命名";
            Boolean tr = true;
            while (tr)
            {
                Console.WriteLine("请选择对方角色<1.刘备 2.孙权 3.曹操>");
                int key = int.Parse(Console.ReadLine());
                switch (key)
                {
                    case 1:
                        ing = "刘备";
                        tr = false;
                        break;
                    case 2:
                        ing = "孙权";
                        tr = false;
                        break;
                    case 3:
                        ing = "曹操";
                        tr = false;
                        break;
                    default:
                        Console.WriteLine("输入错误，请重新输入！");
                        break;
                }
            }
            Opposite oppo = new Opposite(ing);
            //游戏次数
            int z = 0;
            //刘备赢多少
            int g = 0;
            //我赢的次数
            int t = 0;
            Console.WriteLine("请输入您的姓名");
            string Name = Console.ReadLine();
            Oneself oneself = new Oneself(Name);
            oneself.Test01();
            Console.WriteLine("开始游戏吗？<y/n>");
            string k = Console.ReadLine();
            Boolean n = true;
            while (n)
            {
                switch (k)
                {
                    case "y":
                        z++;
                        Console.WriteLine();
                        int e = 0;
                        while (true)
                        {
                            try
                            {
                                Console.WriteLine("请出拳：1.剪刀 2.石头 3.布");
                                e = int.Parse(Console.ReadLine());
                                oneself.Test03(e);
                                break;
                            }
                            catch (Exception)
                            {
                                Console.WriteLine("输入错误，请重新输入");
                            }
                        }
                        oneself.Test();
                        int a = Opposite.Test01();
                        oppo.Test();
                        if (a == e)
                        {
                            Console.WriteLine("和局，真衰！嘿嘿，等着瞧吧！");
                        }
                        else if ((e == 1 && a == 3) || (e == 2 && a == 1) || (e == 3 && a == 2))
                        {
                            Console.WriteLine("恭喜，{0}赢了", oneself.name);
                            t++;
                        }
                        else
                        {
                            Console.WriteLine("笨蛋，{0}输了", oneself.name);
                            g++;
                        }
                        Console.WriteLine("是否开始下一轮比赛<y/n>");
                        string q = Console.ReadLine();
                        switch (q)
                        {
                            case "y":
                                n = true;
                                break;
                            case "n":
                                n = false;
                                Console.WriteLine("===============================================");
                                oneself.Test01();
                                Console.WriteLine("对战次数：{0}", z);

                                Console.WriteLine();
                                Console.WriteLine("姓名\t得分");
                                Console.WriteLine("{0} \t{1}", oneself.name, t);
                                Console.WriteLine("{0} \t{1}", Opposite.Name, g);
                                if (t == g)
                                {
                                    Console.WriteLine("平局，{0}，{1}，两个笨蛋",oppo.name,oneself.name);
                                }
                                else if (t > g)
                                {
                                    Console.WriteLine("{0}赢，{1}笨蛋", oneself.name, Opposite.Name);
                                }
                                else if (t < g)
                                {
                                    Console.WriteLine("{0}赢，{1}笨蛋", Opposite.Name, oneself.name);
                                }
                                Console.WriteLine("要进行下一局比赛吗？<y/n>");
                                string ke = Console.ReadLine();
                                switch (ke)
                                {
                                    case "y":
                                        n = true;
                                        z = 0;
                                        g = 0;
                                        t = 0;
                                        break;
                                    case "n":
                                        Console.WriteLine("系统退出");
                                        n = false;
                                        break;
                                    default:
                                        break;
                                }
                                break;
                            default:
                                Console.WriteLine("输入错误，请重新输入！");
                                Console.WriteLine("是否开始下一轮比赛<y/n>");
                                q = Console.ReadLine();
                                break;
                        }
                        break;
                    case "n":
                        Console.WriteLine("系统退出");
                        n = false;
                        break;
                    default:
                        Console.WriteLine("输入错误，请重新输入！");
                        Console.WriteLine("开始游戏吗？<y/n>");
                        k = Console.ReadLine();
                        break;
                }
            }
        }
    }
}
